import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

bool turn_on = true;
bool mic_on = false;

int rgbIndex = 0;
String ledNum = '200'; // 存储输入的值

String rgbIndexKey = 'rgbIndexKey';
String ledNumKey = 'ledNumKey';

///主题背景颜色
const Color Color_red = Color(0xFFCC2D1F);
const Color Color_mid = Color(0xFF4088B0);
const Color Color_theme = Color(0xFF87322c);
const Color Color_bg_view = Color(0xFFEFF0F2);
const Color Color_bg_btn = Color(0xFFE2E3E6);
const Color Color_border = Colors.black;
const Color Color_bg_view2 = Color(0xFF39393D);
const Color Color_disEnable = Color(0xFF8F989C);
const Color Color_purple = Color(0xFF85519C);
const Color Color_green = Color(0xFF6CB930);
const Color Color_thumbColor = Color(0xFF292F74);
const Color Color_inTrackColor = Color(0xFFD5DBE3);

// const fontNormal = TextStyle(fontWeight: FontWeight.w600, color: Colors.black);
// const font20 = TextStyle(color: Colors.black, fontWeight: FontWeight.w600, fontSize: 20);
// const font30 = TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 30);
const BankFont = 'BankFont';

final fontNormal = font(null);
final font14 = font(14);
final font20 = font(20);
final font30 = font(30);
final font40 = font(40);

TextStyle font(double? font) {
  return TextStyle(
    color: Colors.black,
    fontFamily: BankFont,
    fontWeight: FontWeight.bold,
    height: 1.0,
    fontSize: font ?? 16,
  );
}

BoxDecoration boxDecoration(double radius) {
  return BoxDecoration(
    borderRadius: BorderRadius.circular(radius),
    border: Border.all(color: Colors.black, width: 1),
  );
}

BoxDecoration boxDecorationWithColor(double radius, Color color) {
  return BoxDecoration(
    borderRadius: BorderRadius.circular(radius),
    color: color,
    border: Border.all(color: Colors.black, width: 1),
  );
}

const LinearGradient localGradient = LinearGradient(
  begin: Alignment.topLeft, // 渐变的开始位置，左边
  end: Alignment.bottomRight, // 渐变的结束位置，右边
  colors: [
    Colors.black, // 起始颜色
    Colors.purple, // 结束颜色
  ],
);

// // 保存字符串
// Future<void> saveString(String key, String value) async {
//   final prefs = await SharedPreferences.getInstance();
//   await prefs.setString(key, value);
// }

// // 获取字符串
// Future<String?> getString(String key) async {
//   final prefs = await SharedPreferences.getInstance();
//   return prefs.getString(key);
// }

class GlobalConfig {
  static double scaleH = 0.0;
}

class assets {
  static const String _basePath = 'assets/images/';

  static String getImagePath(String imageName) {
    return '$_basePath$imageName.png';
  }

  // 定义具体的图片资源

  //首页
  static const String app_select = '${_basePath}app_select.png';
  static const String app = '${_basePath}app.png';
  static const String arrow_left = '${_basePath}arrow_left.png';
  static const String arrow_right = '${_basePath}arrow_right.png';
  static const String arrow_up = '${_basePath}arrow_up.png';
  static const String arrow_down = '${_basePath}arrow_down.png';
  static const String bluetooh_select = '${_basePath}bluetooh_select.png';
  static const String bluetooth = '${_basePath}bluetooth.png';
  static const String cancel = '${_basePath}cancel.png';
  static const String files = '${_basePath}files.png';
  static const String files_select = '${_basePath}files_select.png';
  static const String logo = '${_basePath}logo.png';
  static const String refresh = '${_basePath}refresh.png';
  static const String refresh_black = '${_basePath}refresh_black.png';
  static const String select = '${_basePath}select.png';
  static const String settings_select = '${_basePath}settings_select.png';
  static const String settings = '${_basePath}settings.png';
  static const String setup = '${_basePath}setup.png';
  static const String unselect = '${_basePath}unselect.png';
  static const String voice_select = '${_basePath}voice_select.png';
  static const String voice = '${_basePath}voice.png';

  ///读取本地文件
  static Future<Uint8List?> readBinFile(String fileName) async {
    try {
      // 读取 bin 文件
      ByteData data = await rootBundle.load('assets/$fileName');

      // 将 ByteData 转换为 Uint8List 并返回
      return data.buffer.asUint8List();
    } catch (e) {
      print('Error reading bin file: $e');
      return null;
    }
  }
}
